<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form>
    原数据:<input id="old" type="text">
    操作:
    <input type="button" value="转大写" onclick="fun('upper')">
    <input type="button" value="转小写" onclick="fun('lower')">
    新数据:<input id="new" type="text">
</form>
</body>
<script>
    var fun=function (opt) {
        var str=document.getElementById('old').value;
        switch (opt) {
            case 'upper':
                str=str.toUpperCase();
                break;
            case 'lower':
                str=str.toLowerCase();
        }
        document.getElementById('new').value=str;
    }
</script>
</html>